package com.cdks.wuxiu.api.util;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class TimeUtils {
    /**
     * 获取当前时间戳 毫秒
     */
    public static long getTimeMillis() {
        return System.currentTimeMillis();
    }

    /**
     * 获取当前时间戳 秒
     */
    public static long getTimeSecond() {
        return System.currentTimeMillis() / 1000;
    }

    /**
     * 获取当前时间LocalDateTime
     */
    public static LocalDateTime getLocalDateTime() {
        return LocalDateTime.now();
    }

    /**
     * 获取当前时间字符串
     */
    public static String getLocalDateTime(String pattern) {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern(pattern);

		return LocalDateTime.now().format(dtf);
    }

    /**
     * 格式化时间字符串
     */
    public static String getLocalDateTime(String pattern, long time) {
        Date date  = new Date(time * 1000);
        SimpleDateFormat format  = new SimpleDateFormat(pattern);

		return format.format(date);
    }
}
